{include file='public/header' /}
<body>

    <div class="layui-fluid">

        <div class="layui-row">

            <form class="layui-form " enctype="multipart/form-data" id="file" style="margin: 50px;">

                <!-- 上级分类 -->
                <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">*</span>选择品牌

                    </label>

                    <div class="layui-input-block">

                        <select class="valid" id="pid" lay-filter="check_type" name="pid">

                            <option value="0">汽车品牌</option>
                            {foreach $storeList as $vo}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/foreach}

                        </select>

                    </div>

                </div>


                <!-- 分类名称 -->

                <div class="layui-form-item">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">

                            *

                        </span>

                        车型名称

                    </label>

                    <div class="layui-input-block ">

                        <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入车型名称" class="layui-input">

                    </div>

                </div>


                  <!-- 大写首字母 -->

                <div class="layui-form-item" id="dxzm">

                    <label class="layui-form-label" for="name">

                        <span class="x-red">

                            *

                        </span>

                        大写首字母

                    </label>

                    <div class="layui-input-block ">

                        <input type="text" name="zimu" autocomplete="off" placeholder="请输入大写首字母" class="layui-input">

                    </div>

                </div>



                
                <div class="layui-form-item">

                    <label class="layui-form-label" for="L_repass">

                    </label>

                    <button class="layui-btn" id="submitBtn" lay-filter="add" lay-submit="" type="submit">

                        确定录入

                    </button>

                </div>

            </form>

        </div>

    </div>




     <script>
        layui.use(['form', 'jquery'], function(){
            var form = layui.form
            form.on('select(check_type)', function(data){
                var id = data.value;

                if (id == 0) {
                   $('#dxzm').show();

                }else{
                   $('#dxzm').hide();
                }
                
            });
        });
    </script>


    <script>

        layui.config({
            base: '__ROOT__/static/admin/lib/layui/lay/modules/',
        })
        // 只需要引入multiSelect模块即可
        layui.use(['multiSelect'],function() {
            
        });

        layui.use(['form', 'layer', 'upload'], function() {

            $ = layui.jquery;

            var form = layui.form

            ,layer = layui.layer

            ,upload = layui.upload;
            
            //自定义验证规则

            form.verify({

                name: function(value) {

                    if (value.length < 2) {

                        return '昵称至少得2个字符啊';

                    }

                }

            });
        });



        //获取form表单的节点
          fileEle = document.getElementById('file');

          arr = [];

          //把value的值拿出来

          valEle = '';

          nulEle = '';


          $("#file").on("submit",function(){

            //阻止form默认提交
            var evt = event;

            evt.preventDefault();

            //得到formData

            var formData = new FormData($(this)[0]);

            $.ajax({

              url:"{:url('Car/add')}",

              type:"post",

              async: false,

              cache: false,

              contentType: false,

              processData: false,

              data:formData,

              success:function(data){

                if (data.code == 1) {

                  layer.msg(data.message, {icon: 1,time: 1500});

                  setTimeout(function(){
                    //刷新父页面
                    window.parent.location.reload(); 
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name); 
                    //关闭当前frame
                    parent.layer.close(index);

                  },1500);


                }else{

                  layer.msg(data.message, {icon: 2,time: 1500});

                }

                

              }

            })

          })

    </script>

</body>

